package com.cxx.purchasecharge.dal;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.cxx.purchasecharge.core.model.persistence.Goods;
import com.cxx.purchasecharge.core.model.persistence.GoodsType;
import com.cxx.purchasecharge.dal.common.GenericCRUDDao;

@Transactional
public interface GoodsDao extends GenericCRUDDao <Goods, Long>, GoodsDaoPlus
{

    public Goods findById (long id);

    @Query (value = "select g from Goods g where g.name=?1")
    public Goods findByName (String name);

    @Query (value = "select g from Goods g where g.barCode=?1")
    public Goods findByBarCode (String barCode);

    @Query (value = "select g from Goods g where g.type=?1")
    public List <Goods> findByType (GoodsType type);

}
